using System;
using System.Collections.Generic;
using System.Linq;

namespace DIS_WEB_Client.Repositories
{
	#region using
	using DIS_WEB_Client.Models;
	using DIS_WEB_Client.Helpers;
    using DIS_WEB_Client.DIS_BUS_WS;
	#endregion
	public class WeeklyReportRepository
	{
		public WeeklyReportDTO SelectByID(int id)
		{
			try
			{
                return BusService.Instance.WeeklyReport_SelectByID(id);
			}
			catch(Exception ex)
			{
				if (ex.InnerException != null)
				{
					GlobalVariables.Logger.Error(ex.InnerException.Message);
				}
				else
				{
					GlobalVariables.Logger.Error(ex.Message);
				}
			}
			return null;
		}

		public bool Insert(WeeklyReportDTO obj)
		{
			try
			{
                return BusService.Instance.WeeklyReport_Insert(obj);
			}
			catch(Exception ex)
			{
				if (ex.InnerException != null)
				{
					GlobalVariables.Logger.Error(ex.InnerException.Message);
				}
				else
				{
					GlobalVariables.Logger.Error(ex.Message);
				}
			}
			return false;
		}

		public bool Delete(int id)
		{
			try
			{
                return BusService.Instance.WeeklyReport_Delete(id);
			}
			catch(Exception ex)
			{
				if (ex.InnerException != null)
				{
					GlobalVariables.Logger.Error(ex.InnerException.Message);
				}
				else
				{
					GlobalVariables.Logger.Error(ex.Message);
				}
			}
			return false;
		}

		public bool Update(WeeklyReportDTO obj)
		{
			try
			{
                return BusService.Instance.WeeklyReport_Update(obj);
			}
			catch(Exception ex)
			{
				if (ex.InnerException != null)
				{
					GlobalVariables.Logger.Error(ex.InnerException.Message);
				}
				else
				{
					GlobalVariables.Logger.Error(ex.Message);
				}
			}
			return false;
		}

		public List<WeeklyReportDTO> RetrieveByID(int id)
		{
			try
			{
                return BusService.Instance.WeeklyReport_RetrieveByID(id).ToList();
			}
			catch(Exception ex)
			{
				if (ex.InnerException != null)
				{
					GlobalVariables.Logger.Error(ex.InnerException.Message);
				}
				else
				{
					GlobalVariables.Logger.Error(ex.Message);
				}
			}
			return new List<WeeklyReportDTO>();
		}

		public List<WeeklyReportDTO> SelectByIDChemistWareHouse(int idChemistWareHouse)
		{
			try
			{
                return BusService.Instance.WeeklyReport_SelectByIDChemistWareHouse(idChemistWareHouse).ToList();
			}
			catch(Exception ex)
			{
				if (ex.InnerException != null)
				{
					GlobalVariables.Logger.Error(ex.InnerException.Message);
				}
				else
				{
					GlobalVariables.Logger.Error(ex.Message);
				}
			}
			return new List<WeeklyReportDTO>();
		}

        public WeeklyReportDTO SelectByIDChemistWareHouseAndReportDate(int idChemistWareHouse, DateTime startdate, DateTime enddate)
        {
            try
            {
                return BusService.Instance.WeeklyReport_SelectByIDChemistWareHouseAndReportDate(idChemistWareHouse, startdate, enddate);
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    GlobalVariables.Logger.Error(ex.InnerException.Message);
                }
                else
                {
                    GlobalVariables.Logger.Error(ex.Message);
                }
            }
            return null;
        }
	}
}